package com.cndw.kungfu.vo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.cndw.kungfu.domain.Pet;
import com.cndw.kungfu.domain.SkillMode;
import com.cndw.kungfu.model.Context;
import com.cndw.kungfu.model.pet.domain.PetSoul;
import com.cndw.kungfu.model.pet.domain.Soul;

public class PetVO {

	public long id;
	/**
	 * 名称
	 */
	private String name;
	/**
	 * 模型
	 */
	private int modeId;
	
	private int level;
	/**
	 * 成长值
	 */
	private int growth;
	/**
	 * 星级,进化次数
	 */
	private int star;
	/**
	 * 灵性修炼
	 */
	private int spirit;
	/**
	 * 悟性,修炼
	 */
	private int perception;
	/**
	 * 经验
	 */
	private long exp;
	//基础属性
	private int hp;	
	private int mp;	
	private int maxHp;	
	private int maxMp;	
	private int attack;	
	private int defense;	
	private int hit;
	private int dodge;	
	private int crit;
	private int tough;
	private int speed;
	/**
	 * 战力评分
	 */
	private int score;
	
	private String icon;
	
	private long expNeed;
	
	private int skillGird;
	
	private List<SkillModeVO> skillModes;
	
	private List<PetSoulVO> souls;
	
	private int huntScore;
	
	public PetVO(){
		
	}
	
	public PetVO(Pet pet){
		id = pet.getId();
		name = pet.getName();
		modeId = pet.getModeId();
		level = pet.getLevel();
		growth = pet.getGrowth();
		star = pet.getStar();
		spirit = pet.getSpirit();
		perception = pet.getPerception();
		exp = pet.getExp();
		hp = pet.getHp();
		mp = pet.getMp();
		maxHp = pet.getMaxHp();
		maxMp = pet.getMaxMp();
		attack = pet.getAttack();
		defense = pet.getDefense();
		hit = pet.getHit();
		dodge = pet.getDodge();
		crit = pet.getCrit();
		tough = pet.getTough();
		speed = pet.getSpeed();
		icon = pet.getMode().getIcon();
		if (pet.getSkillIds() != null && pet.getSkillIds().length > 0) {
			skillModes = new ArrayList<SkillModeVO>();
			for (int i = 0; i < pet.getSkillIds().length; i++) {
				int eid = pet.getSkillIds()[i];
				SkillMode skillMode = Context.getSkillServer().getSkillMode(eid);
				if (skillMode != null) {
					skillModes.add(skillMode.toSkillModeVO());
				}
			}			
		}
		
		if (pet.getHuntsMap() != null && !pet.getHuntsMap().isEmpty()) {
			int eHp = 0, eMp = 0, eAttack = 0, eDefense = 0, eSpeed = 0, eHit = 0, eDodge = 0, eCrit = 0, eTough = 0;
			souls = new ArrayList<PetSoulVO>();
			for (Map.Entry<Integer, Soul> entry : pet.getHuntsMap().entrySet()) {
				PetSoul petSoul = Context.getPetServer().getSoul(entry.getValue().getId());
				if (petSoul == null) {
					continue;
				}
				int[] skillAdd = petSoul.getAddV();
				if (skillAdd != null && skillAdd.length >= 8) {
					eHit += skillAdd[0];
					eDodge += skillAdd[1];
					eCrit += skillAdd[2];
					eTough += skillAdd[3];
					eAttack += skillAdd[4];
					eDefense += skillAdd[5];
					eHp += skillAdd[6];
					eMp += skillAdd[7];
					eSpeed += skillAdd[8];
				}

				
				PetSoulVO e = new PetSoulVO(entry.getKey(), entry.getValue().getExp(), petSoul);
				souls.add(e);
			}
			huntScore = (eHp + eMp) / 10 + (eAttack + eDefense) / 3 + (eHit + eDodge + eCrit + eTough + eSpeed) / 2;
			huntScore = huntScore / 10;
		}
		score = pet.getScore();
		
		expNeed = pet.getExpNeed();
		
		skillGird = pet.getSkillGird();
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getModeId() {
		return modeId;
	}
	public void setModeId(int modeId) {
		this.modeId = modeId;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
	public int getGrowth() {
		return growth;
	}
	public void setGrowth(int growth) {
		this.growth = growth;
	}
	public int getStar() {
		return star;
	}
	public void setStar(int star) {
		this.star = star;
	}
	public int getPerception() {
		return perception;
	}
	public void setPerception(int perception) {
		this.perception = perception;
	}
	public long getExp() {
		return exp;
	}
	public void setExp(long exp) {
		this.exp = exp;
	}
	public int getHp() {
		return hp;
	}
	public void setHp(int hp) {
		this.hp = hp;
	}
	public int getMp() {
		return mp;
	}
	public void setMp(int mp) {
		this.mp = mp;
	}
	public int getMaxHp() {
		return maxHp;
	}
	public void setMaxHp(int maxHp) {
		this.maxHp = maxHp;
	}
	public int getMaxMp() {
		return maxMp;
	}
	public void setMaxMp(int maxMp) {
		this.maxMp = maxMp;
	}
	public int getAttack() {
		return attack;
	}
	public void setAttack(int attack) {
		this.attack = attack;
	}
	public int getDefense() {
		return defense;
	}
	public void setDefense(int defense) {
		this.defense = defense;
	}
	public int getHit() {
		return hit;
	}
	public void setHit(int hit) {
		this.hit = hit;
	}
	public int getDodge() {
		return dodge;
	}
	public void setDodge(int dodge) {
		this.dodge = dodge;
	}
	public int getCrit() {
		return crit;
	}
	public void setCrit(int crit) {
		this.crit = crit;
	}
	public int getTough() {
		return tough;
	}
	public void setTough(int tough) {
		this.tough = tough;
	}
	public int getSpeed() {
		return speed;
	}
	public void setSpeed(int speed) {
		this.speed = speed;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	public List<SkillModeVO> getSkillModes() {
		return skillModes;
	}
	public void setSkillModes(List<SkillModeVO> skillModes) {
		this.skillModes = skillModes;
	}
	public long getExpNeed() {
		return expNeed;
	}
	public void setExpNeed(long expNeed) {
		this.expNeed = expNeed;
	}
	public int getSkillGird() {
		return skillGird;
	}
	public void setSkillGird(int skillGird) {
		this.skillGird = skillGird;
	}
	public List<PetSoulVO> getSouls() {
		return souls;
	}
	public void setSouls(List<PetSoulVO> souls) {
		this.souls = souls;
	}
	public int getHuntScore() {
		return huntScore;
	}
	public void setHuntScore(int huntScore) {
		this.huntScore = huntScore;
	}

	public int getSpirit() {
		return spirit;
	}

	public void setSpirit(int spirit) {
		this.spirit = spirit;
	}
	
	
	
}
